package com.eqdd.yiqidian.ui.gongneng.renshi.check;

import android.os.Bundle;
import android.view.View;

import com.eqdd.annotation.datasave.DealCodeClass;
import com.eqdd.yiqidian.R;
import com.eqdd.yiqidian.box.ItemDecoration.SectionDividerItemDecoration;
import com.eqdd.yiqidian.base.CodeRule;
import com.eqdd.yiqidian.base.Config;
import com.eqdd.yiqidian.bean.EnterBean;
import com.eqdd.yiqidian.bean.rebuild.CommonTabBean;
import com.eqdd.yiqidian.bean.rebuild.LayoutMapBean;
import com.eqdd.yiqidian.http.HttpConfig;
import com.eqdd.yiqidian.rxbus2.RxBus;
import com.eqdd.yiqidian.ui.base.BaseEnterActivity;
import com.eqdd.yiqidian.ui.mine.pizhun.MissClockInfoActivity;
import com.eqdd.yiqidian.ui.mine.pizhun.MyPiZhunInfoActivity;
import com.eqdd.yiqidian.ui.mine.pizhun.SickLeaveInfoActivity;
import com.eqdd.yiqidian.ui.mine.shenqing.ApplyMissClockActivity;
import com.eqdd.yiqidian.ui.mine.shenqing.ApplySickLeaveActivity;
import com.eqdd.yiqidian.utils.DensityUtil;
import com.eqdd.yiqidian.utils.ToastUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by lvzhihao on 17-4-19.
 */

public class HRCheckActivity extends BaseEnterActivity {
    private Class[] classes = new Class[]{
            ShowHRLeaveCheckActivity.class,
            ShowHRTravelCheckActivity.class,
            ShowHROverTimeCheckActivity.class,
            ShowHROffCheckActivity.class,
            ShowHRChangeShiftCheckActivity.class,
            ShowHRChidaozaotuiActivity.class,
            ShowHRLoudakaActivity.class,
            ShowHRLizhiActivity.class,
            ShowHRRenliCheckActivity.class,
            ShowHRTrainActivity.class

    };
    private List<CommonTabBean> commonTabBeans = new ArrayList<>();

    @DealCodeClass(classes = {ShowHRLeaveCheckActivity.class})
    public void updateQingjia(int num) {
        updateNum(0);
    }

    @DealCodeClass(classes = {ShowHRTravelCheckActivity.class})
    public void updateChuchai(int num) {
        updateNum(1);
    }

    @DealCodeClass(classes = {ShowHROverTimeCheckActivity.class})
    public void updateJiaban(int num) {
        updateNum(2);
    }

    @DealCodeClass(classes = {ShowHROffCheckActivity.class})
    public void updateTiaoxiu(int num) {
        updateNum(3);
    }

    @DealCodeClass(classes = {ShowHRChangeShiftCheckActivity.class})
    public void updateTiaoban(int num) {
        updateNum(4);
    }

    @DealCodeClass(classes = {ShowHRChidaozaotuiActivity.class})
    public void updateChidaozaotui(int num) {
        updateNum(5);
    }

    @DealCodeClass(classes = {ShowHRLoudakaActivity.class})
    public void updateLoudaka(int num) {
        updateNum(6);
    }

    @DealCodeClass(classes = {ShowHRLizhiActivity.class})
    public void updateLizhi(int num) {
        updateNum(7);
    }

    @Override
    public void itemClick(int p) {
        if (commonTabBeans.get(p) != null) {
            Bundle bundle = new Bundle();
            bundle.putSerializable("bean", commonTabBeans.get(p));
            startActivity(classes[p], bundle);
        } else if (classes[p] != null) {
            startActivity(classes[p]);
        } else {
            ToastUtil.showShort("该模块暂未开发");
        }
    }

    @Override
    public void initEnterData() {
        isDealCode = true;
        RxBus.getDefault().register(this);
        initTopTitleBar(View.VISIBLE, "人事审批");
        enterBeans.add(new EnterBean("请假").setCode(CodeRule.SHENGPI_HR_QINGJIA));
        enterBeans.add(new EnterBean("出差").setCode(CodeRule.SHENGPI_HR_CHUCHAI));
        enterBeans.add(new EnterBean("加班").setCode(CodeRule.SHENGPI_HR_JIABAN));
        enterBeans.add(new EnterBean("调休").setCode(CodeRule.SHENGPI_HR_TIAOXIU));
        enterBeans.add(new EnterBean("调班").setCode(CodeRule.SHENGPI_HR_TIAOBAN));
        enterBeans.add(new EnterBean("迟到早退").setCode(CodeRule.SHENGPI_HR_CHIDAOZAOTUI));
        enterBeans.add(new EnterBean("漏打卡").setCode(CodeRule.SHENGPI_HR_LOUDAKA));
        enterBeans.add(new EnterBean("离职审批").setCode(CodeRule.SHENGPI_HR_LIZHI));
        enterBeans.add(new EnterBean("人力需求"));
        enterBeans.add(new EnterBean("培训"));
        commonTabBeans.add(null);
        commonTabBeans.add(null);
        commonTabBeans.add(null);
        commonTabBeans.add(null);
        commonTabBeans.add(null);
        commonTabBeans.add(new CommonTabBean("迟到早退消除列表", Config.APPLY_SICK_LEAVE,
                ApplySickLeaveActivity.class)
                .setRight(false)
                .setWho(2)
                .title("待审核", "已审核")
                .setIdName("sickleaveId")
                .setInfoActivity(SickLeaveInfoActivity.class)
                .setLayoutId(R.layout.list_item_28)
                .map(new LayoutMapBean(R.id.tv_left_content, 6),
                        new LayoutMapBean(R.id.tv_right_hint_content, 7))
                .setUrl(HttpConfig.SICK_LEAVE_HR_LIST));
        commonTabBeans.add(new CommonTabBean("漏打卡消除列表", Config.APPLY_MISS_CLOCK,
                ApplyMissClockActivity.class)
                .setRight(false)
                .setWho(2)
                .title("待审核", "已审核")
                .setIdName("missClockId")
                .setInfoActivity(MissClockInfoActivity.class)
                .setLayoutId(R.layout.list_item_28)
                .map(new LayoutMapBean(R.id.tv_left_content, 8),
                        new LayoutMapBean(R.id.tv_right_hint_content, 7))
                .setUrl(HttpConfig.MISS_CLOCK_HR_LIST));
        commonTabBeans.add(new CommonTabBean("离职审批列表", 0,
                null)
                .title("审批中", "已通过", "未通过")
                .setIdName("quitId")
                .setRight(false)
                .setWho(2)
                .setInfoActivity(MyPiZhunInfoActivity.class)
                .setLayoutId(R.layout.list_item_13)
                .map(new LayoutMapBean(R.id.tv_left_center_content, "getSix"),
                        new LayoutMapBean(R.id.tv_upper_right_content, 1),
                        new LayoutMapBean(R.id.tv_down_right_content, 2))
                .setUrl(HttpConfig.LIZHI_SHENPI_BY_HR_LIST));
        commonTabBeans.add(null);
        commonTabBeans.add(null);

        dataBinding.recyclerView.addItemDecoration(
                new SectionDividerItemDecoration(this)
                        .setLeftPadding(DensityUtil.percentW(30))
                        .setRightPadding(DensityUtil.percentW(30)));

    }
}
